<template>
    <div class="con">
        <input type="text" placeholder="请输入支付宝账号" v-model="account" />
        <div class="btn" @click="ok()">
            <button>确认添加</button>
        </div>
    </div>
</template>

<script>
export default {
    name: "addAlipay",
    data() {
        return {
            timestamp: "",
            account: ""
        };
    },

    methods: {
        ok() {
            if(this.account==""){
                this.$toast("支付宝账号不能为空")
            }else{

                 this.axios({
                method: "post",
                url: `${this.siteUrl}/app/account/repay/setZfbAccount?appid=web.2019&format=json&timestamp=${this.timestamp}`,
                data: {
                    userId: localStorage.getItem("userId"),
                    account: this.account
                }
            })
                .then(response => {
                    console.log(response);
                    if (response.data.success == 1) {
                        this.$toast(response.data.message)
                        this.$router.replace({ name: "qrcode"});

                    }else{
                        this.$toast(response.data.message)
                    }
                })
                .catch(error => {
                    console.log(error);
                    this.$toast("连接服务器异常");
                });

            }
           
        }
    },
    mounted() {
        this.timestamp = Date.parse(new Date());
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.con {
    width: 100%;
    min-height: 100vh;
    background: #f9f9f9;
}

input {
    height: 60px;
    width: 100%;
    font-size: 16px;
    text-indent: 10px;
    margin-top: 10px;
}
input::-webkit-input-placeholder {
    color: #cdd0da;
    font-size: 16px;
    font-weight: 200;
}

.btn {
    width: 90%;
    margin: 36px auto 24px;
    height: 48px;
    line-height: 48px;
    background: #ffae4e;
    text-align: center;
    border-radius: 25px;
}
.btn button {
    width: 100%;
    font-size: 17px;
    color: #fff;
    background: transparent;
}
</style>
